/**
* 产品列表 - 跳转的详情 组件
*/
<template>
  <div :class="getName" v-bind="detailD">
    <aside class="h-aside fl">
      <!--<img :src="bigUrl" class="h-big" />-->
      <img :src="bigUrl" class="h-big" />
      <ul class="h-list" v-if="terminal === 'pc'">
        <li @click="handleUrlClick(item)" :key="item.id" v-for="item in detailD.list"><img :src="item.url" /></li>
        <!-- <li @click="handleUrlClick"><img src="@/assets/img/zujin1.jpg" /></li>
        <li @click="handleUrlClick"><img src="@/assets/img/zujin1.jpg" /></li>
        <li @click="handleUrlClick"><img src="@/assets/img/zujin1.jpg" /></li>
        <li @click="handleUrlClick"><img src="@/assets/img/zujin1.jpg" /></li> -->
      </ul>
    </aside>
    <section class="h-section fr">
      <h3 class="mt10">{{detailD.name}}</h3>
      <p>编码 : {{detailD.id}}</p>
      <el-tabs v-model="activeName" @tab-click="handleTabClick">
        <el-tab-pane label="产品描述" name="first">
          {{detailD.content}}
          <template v-if="terminal === 'ph'">
            <div :key="item.id" v-for="(item, index) in detailD.list">
            <img v-if="index !==0 " :src="item.url" />
          </div>
          </template>
        </el-tab-pane>
        <el-tab-pane label="主题系列" name="second">
          {{detailD.theme}}
        </el-tab-pane>
      </el-tabs>
      
      <div v-if="detailD.likenum>0" class="h-like"><i class="iconfont iconshoucang4"></i>喜欢({{detailD.likenum}})</div>
    </section>
  </div>
</template>
<script>
import { detailData } from '@/mock' // 脚部数据
import { WareDetailData } from '@/api'

export default {
  name: 'Details',
  props: {},
  data () {
    return {
      id:this.$route.params.id,
      terminal: '', // 终端类型
      detailD: {},
      activeName: 'first',
      bigUrl: ''
    }
  },
  computed: {
    getName(){
      console.log(this.terminal)
      if(this.terminal === 'pc'){
        return 'h-details'
      } else {
        return 'h-details h-ph'
      }
    }
  },
  created () {
    this.terminal = localStorage.getItem('terminalm')
    console.log('this.terminal***', this.terminal)
     this.getWareDetailData() // 底部数据加载
  },
  mounted () {
    //this.detailD = detailData.result // 使用接口时 此处删除
    //this.bigUrl=this.detailD.url
    console.log(detailData.result)
  },
  methods: {
    getWareDetailData () {
      const params = { // 请求参数 --- 根据情况 是否需要
        id: this.id
      }
      WareDetailData(params).then(res => {
        this.detailD = res
        console.log(this.detailD)
         console.log(this.detailD.url)
        this.bigUrl=this.detailD.url
      })
    },
    handleUrlClick(item){
      console.log(item)
       console.log(item.url)
      this.bigUrl = item.url
    },
    handleTabClick(){
      
    },
  }
}
</script>

<style lang="scss" scoped>
  .h-details {
    margin-bottom: 20px;
    overflow: hidden;
    .h-aside{
      width: 460px;
    }
    .h-big{
      display: block;
      width: 360px;
      height: 360px;
      margin: 10px auto;
    }
    .h-list{
      padding: 0 0 10px 10px;
      border: 1px solid #dcdcdc;
      overflow: hidden;
      li{
        width: 66px;
        height: 66px;
        margin: 0 10px 10px 0;
        float: left;
        cursor: pointer;
        img{
          width: 100%;
          height: 100%;
        }
      }
    }
    .h-section{
      width: 550px;
      h3{
        font-weight: normal;
        color: #333;
      }
      p{
        margin: 10px 0 50px 0;
        font-size: 12px;
        color: #666;
      }
      .h-like{
        width: 310px;
        padding-top: 5px;
        margin-top: 50px;
        border-top: 1px solid #900028;
        i{
          margin-right: 5px;
          color: #900028;
        }
      }
    }
  }
  /* 移动端 */
  .h-details.h-ph{
    .h-aside, .h-section{
      width: 100%;
      padding: 0 15px;
      box-sizing: border-box;
      img{
        width: 100%;
        height: auto;
      }
    }
    .h-like{
      width: 70%;
    }
  }
</style>
